A computer program typically includes multiple computing threads, each of which can include one or more activities. An activity can also be referred to as a subroutine, a function, or a function call. An activity, which when executed, can also call another activity. A call stack is a stack data structure conventionally stores information about activities of a thread of the computer program. Each activity has a corresponding stack frame (in the call stack), which stores data for that activity.
To obtain data of a thread with multiple activities at various times, developers usually sample a thread and store data associated with each sample in a call stack associated with the thread. In one example, a developer can sample a thread every millisecond to generate 1000 samples per second, and each activity can span for time typically ranging from microsecond(s) to millisecond(s). Thus, two consecutive samples can encompass portions of one or more activities.
The retrieving and storing of data for each sample of the computing thread is now described. For each sample, a total CPU time is retrieved from the operating system and recorded in the call stack. This total CPU time has been used conventionally to determine hot spots (that is, specific portions of the computer program that use a large amount of the CPU time). However, these traditionally determined hot spots are usually inaccurate, as the total CPU time retrieved from the operating system is not a good indicator of a total time for which the CPU has been servicing. This total CPU time is not a good indicator because CPUs often go in wait states, which are time periods when the CPUs do not service activities of a computer program, and such wait state time periods are not accounted for in the total CPU time. Due to this inaccurate determining of hot spots, developers spend undesirably high amounts of time examining various portions of the code that are already efficient and would not have required examination had there been a more accurate determination of hot spots.